#pragma once

class CFrameRate
{
public: 
	CFrameRate();
	void StartRenderThreadFrame();
	void EndRenderThreadFrame(XUINT32 batchCount);
	void ResetRenderThreadFPS();
	~CFrameRate();
	HRESULT EnsureResources(struct IPALGraphicsDevice * pGraphicsDevice);
	void UpdateUIThreadCounters(XUINT32 currentUIThreadFrameRate, XFLOAT uiThreadCPUTime);
	HRESULT DrawCounters();
private: 
	void WriteCounter(struct CPALVertex * pVertexBuffer, XFLOAT rOffset, XUINT32 cDigits, XUINT32 uCounterValue);
	static const XUINT32 s_counterDigits;
	static const XUINT32 s_memoryDigits;
	static const XUINT32 s_verticesPerDigit;
	static const XUINT32 s_totalVertices;
	struct IPALGraphicsDevice * m_pGraphicsDevice;
	struct IPALSurface * m_pTexture;
	struct IPALGraphicsDeviceBuffer * m_pVertexBuffer;
	XFLOAT m_rFramerateStartTime;
	XUINT32 m_uFPS;
	XUINT32 m_uFramerateStartFrame;
	XUINT32 m_uFrameNumber;
	XFLOAT m_rLastFrameStartTime;
	XFLOAT m_rTotalFrameCPUTime;
	XFLOAT m_rAverageFrameCPUTime;
	struct IPALClock * m_pClock;
	XUINT32 m_batchCount;
	XUINT32 m_currentUIThreadFrameRate;
	XFLOAT m_uiThreadCPUTime;
};